<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
    <head>
        <meta charset="UTF-8">
        <title>welcome</title>
    </head>
    <body style="background-color: mediumvioletred">
        <p>This is a home page.</p>
        <p>Username: <th:block sec:authentication="principal.username"></th:block></p>
        <p>Role: <th:block sec:authentication="principal.authorities"></th:block></p>

        <!--按需show,使用spEL表达式-->
        <a href="/admin" sec:authorize="hasRole('admin')">管理员页面跳转</a>
        <a href="/user" sec:authorize="hasRole('user')">用户登录</a>
        <br/>
        <a href="/logout">退出登录</a>
    </body>
</html>